package com.nlscan.qdkit.ui.publico.config

import android.app.Activity
import android.content.pm.ActivityInfo
import com.nlscan.qdkit.common.core.util.DeviceUtils
import com.nlscan.qdkit.common.core.util.ScreenUtils

/**
 * <pre>
 *  author: lin.qing
 *  time  : 2023/7/5
 *  desc  :
 * </pre>
 */
object PublicoConfigHelper {

    /**
     * 配置默认的activity方向
     * -- 自适应横竖屏，手机竖屏，手表横屏，平板自适应
     */
    @JvmStatic
    fun configDefaultActivityOrientation(activity: Activity) {
        if (PublicoConfig.ADJUST_TABLET_ORIENTATION_ENABLE) {
            val orientation =
                if (DeviceUtils.isTablet()) {
                    if (ScreenUtils.getScreenHeight() > 480) {
                        ActivityInfo.SCREEN_ORIENTATION_SENSOR
                    } else {    //手表
                        ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
                    }
                }
                else ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
            activity.requestedOrientation = orientation
        }
    }

}